fix(math): restore priority-based comment routing (regression from #1961) - #2611
Merged
Conversation
jucor
added a commit
that referenced
this pull request
Jul 17, 2026
…ce (#2612) Adds delphi/docs/MATH_ALGORITHM_HISTORY.md — a git-archaeology reference of the core Polis math algorithms (comment routing, PCA/projection, extremity/repness, clustering, consensus/moderation): introductions, numeric-output-changing edits, and bugs, with verified commit hashes and dates. Includes the 2025 comment-routing regression (#1961, fixed in #2611), the pre-2018 uniform-random routing history, and how to map conversations to algorithm versions via the prod deploy timeline. Sourced entirely from public git history and code — no production data. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> commit-id:31321c47
Contributor
There was a problem hiding this comment.
Pull request overview
Restores the intended priority-weighted comment routing by fixing meta-comment detection in the Clojure math pipeline (preventing all comments from being treated as meta due to Clojure truthiness of 0). This re-enables non-uniform priorities so downstream routing (TS server sampling) behaves as designed.
Changes:
- Fix
:comment-prioritiesto pass a real boolean topriority-metricvia(contains? meta-tids tid). - Document the parity implications and current Python↔Clojure priority mismatch in the Delphi parity planning docs.
- Add an append-only journal entry describing the regression, fix, and discovered parity blocker.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| math/src/polismath/math/conversation.clj | Fixes meta detection for priority computation to prevent all priorities collapsing to 49. |
| delphi/docs/PLAN_DISCREPANCY_FIXES.md | Notes the newly-unmasked D12 parity blocker and cautions against un-mirroring Python yet. |
| delphi/docs/CLJ-PARITY-FIXES-JOURNAL.md | Records the routing regression fix and the discovered non-parity details for future follow-up work. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
) The `:comment-priorities` node passed the meta-tid lookup value `(if meta-tids (get meta-tids tid 0) 0)` into `priority-metric`'s `is-meta` argument. `(get meta-tids tid 0)` returns `0` for non-meta tids, and `0` is TRUTHY in Clojure, so `(if is-meta ...)` took the meta branch for EVERY comment — every priority collapsed to `meta-priority^2 = 49`. The TypeScript server's `selectProbabilistically` then degraded to uniform-random next-comment selection, reverting routing to its pre-2018 behavior. Introduced by #1961 (2025-03-15, "cutoff for large-convo processing if > 5000 comments"), which changed the meta-tid default from `(meta-tids tid)` (nil for non-meta) to `(get meta-tids tid 0)`. Fix: pass a real boolean — `(priority-metric (contains? meta-tids tid) ...)`. `contains?` is false for a non-meta tid and false when `meta-tids` is nil, restoring meta=49 / non-meta=importance*novelty. Verified end-to-end: a math image built with this fix regenerates the vw cold-start blob with varied priorities (125 distinct, 5.16-61.95) instead of all-49. Scope: Clojure only, which is what feeds production routing. The Python port still mirrors the bug (`priority_metric` returns META_PRIORITY**2). Un-mirroring it revealed that Python and Clojure priorities are not yet at parity (rank-uncorrelated on vw), so the Python un-mirror + cold-start blob regeneration is deferred to #2571, pending extremity/PCA parity (D1/D1b). See delphi/docs/CLJ-PARITY-FIXES-JOURNAL.md (2026-07-17). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> commit-id:ec8e2093
This was referenced Jul 17, 2026
Draft
This was referenced Jul 22, 2026
colinmegill
pushed a commit
that referenced
this pull request
Sep 8, 2026
…gression reference Adds `delphi/docs/MATH_ALGORITHM_HISTORY.md` — a git-archaeology reference of the core Polis math algorithms (comment routing, PCA/projection, extremity/repness, clustering, consensus/moderation): when each was introduced, every edit that changed numeric output, and known bugs, with verified commit hashes and dates. It includes the 2025 comment-routing regression (#1961, fixed in #2611), the pre-2018 uniform-random routing history, and a guide to mapping conversations to algorithm versions via the production deploy timeline. Sourced entirely from public git history and code — no production data. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> commit-id:31321c47
colinmegill
pushed a commit
that referenced
this pull request
Sep 8, 2026
…d) + Q2 prev-tick group-votes ## What Two changes to comment prioritization: - Restore the real `priority_metric` branching formula in BOTH engine modes. Clojure HEAD passes a real boolean since #2611 (conversation.clj:686, merged 2026-07-18), so the all-49 mirror of bug #1961 (the meta-tid routing bug that flattened every comment's priority to ~49, which #2571 had us reproduce for parity) is no longer the parity behavior — the correct formula is. - Replicate quirk Q2 (`delphi/docs/CLOJURE_QUIRKS.md`): Clojure's `:comment-priorities` node SHADOWS its current-tick group-votes input with `(:group-votes conv)` — the PREVIOUS tick's stored value (conversation.clj:658). clojure-legacy mode (the engine setting that reproduces the old Clojure engine's behavior exactly) now consumes the captured previous-tick group-votes (`{}` on the first tick, matching Clojure's nil); improved mode keeps the current-tick read. ## How it works The current tick's group-votes are stored on `self.group_votes` each tick in both modes (like `self.pca`), as the in-memory analogue of Clojure persisting `:group-votes` in `math_main` (the math results table). The restart seam — reloading group-votes on `from_dict` / poller reload — is deferred to the poller equivalence phase and noted in the journal. Stale-mirror test sites reworked: - The designed xfail on `test_priority_metric_non_meta_squared` is harvested: the formula test now gates. - `TestD12CommentPriorities` now pins varied (non-all-49) Python output plus coverage, instead of the mirror signature. - The exact-value comparison in `test_legacy_clojure_regression.py::test_comment_priorities` is xfailed for ALL variants — the reference blobs predate the Clojure #2611 fix, so value parity is validated by the H-B replay battery (the `scripts/certify.py` Clojure-vs-Python replay comparison) until the blobs are regenerated with a fixed generator. ## Testing TDD: `tests/test_priority_unmirror.py` — RED observed (formula tests fail on the mirror; prev-tick flow + group_votes storage fail on the old wiring), 7 GREEN after. Targeted runs: 13 passed (unmirror + float-serialization), 21 passed (D12/priority subset), 4 xfailed (legacy regression value comparisons). commit-id:a85047a7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
:comment-prioritiesnode passed the meta-tid lookup value(if meta-tids (get meta-tids tid 0) 0)intopriority-metric'sis-metaargument.
(get meta-tids tid 0)returns0for non-meta tids, and0isTRUTHY in Clojure, so
(if is-meta ...)took the meta branch for EVERYcomment — every priority collapsed to
meta-priority^2 = 49. The TypeScriptserver's
selectProbabilisticallythen degraded to uniform-random next-commentselection, reverting routing to its pre-2018 behavior.
Introduced by #1961 (2025-03-15, "cutoff for large-convo processing if
Fix: pass a real boolean —
(priority-metric (contains? meta-tids tid) ...).contains?is false for a non-meta tid and false whenmeta-tidsis nil,restoring meta=49 / non-meta=importance*novelty.
Verified end-to-end: a math image built with this fix regenerates the vw
cold-start blob with varied priorities (125 distinct, 5.16-61.95) instead of
all-49.
Scope: Clojure only, which is what feeds production routing. The Python port
still mirrors the bug (
priority_metricreturns META_PRIORITY**2). Un-mirroringit revealed that Python and Clojure priorities are not yet at parity
(rank-uncorrelated on vw), so the Python un-mirror + cold-start blob
regeneration is deferred to #2571, pending extremity/PCA parity (D1/D1b).
See delphi/docs/CLJ-PARITY-FIXES-JOURNAL.md (2026-07-17).
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
commit-id:ec8e2093
Stack: